1 /**
2 * Copyright 2008 WebPhotos
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16 /*
17 * To change this template, choose Tools | Templates
18 * and open the template in the editor.
19 */
20
21 package net.sf.webphotos.util;
22
23 import org.springframework.context.ApplicationContext;
24 import org.springframework.context.support.ClassPathXmlApplicationContext;
25
26 /**
27 *
28 * @author Guilhe
29 */
30 public class ApplicationContextResource {
31
32 private static ApplicationContext applicationContext;
33
34 static {
35 String[] configLocations = {"classpath*:applicationContext.xml", "applicationContext.xml"};
36 applicationContext = new ClassPathXmlApplicationContext(configLocations);
37 }
38
39 private ApplicationContextResource() {
40
41 }
42
43 public static Object getBean(String name) {
44 return applicationContext.getBean(name);
45 }
46
47 }